import { request } from '../utils/request.js'

// 新增（提交订单）
export const addOrderService = (data) =>
  request({ url: '/userOrder/addOrder', data, method: 'POST' })

// 新增订单中的甜品信息
export const addOrderDetailService = (data) =>
  request({ url: '/userOrderDetail/addUserOrderDetail', data, method: 'POST' })

// 根据用户id获取所有订单
export const getOrderByUser = (userId, type) =>
  request({ url: `/userOrder/findOrderByUser?userId=${userId}&type=${type}`})

//根据订单id获取订单详情
export const getOrderDetailService = (orderId) =>
  request({ url: `/userOrderDetail/getUserOrderDetail/${orderId}` })

// 确认收货
export const confirmOrderService = (data) =>
  request({ url: `/userOrder/markOrder`, data, method: 'POST' })

// 提交DIY预订订单
export const addDiyOrderService = (data) =>
  request({ url: '/diyOrder/addDiyOrder', data, method: 'POST' })

// 根据用户id获取所有DIY订单
export const getDiyOrderByUser = (userId, type) =>
  request({ url: `/dessert/findDiyOrderByUser`, param: {userId, type}})
  
// 确认完成订单
export const confirmDiyOrderService = (data) =>
  request({ url: `/dessert/markDiyOrder`, data, method: 'POST' })
